package it.poste.il.compensatore.dao.impl;

import it.poste.il.compensatore.dao.OperationDao;
import it.poste.il.compensatore.entity.Operation;
import java.util.List;

import javax.persistence.NoResultException;

import org.springframework.transaction.annotation.Transactional;

public class OperationDaoImpl extends BaseEntityDaoImpl<Operation> implements OperationDao {
    public OperationDaoImpl() {
        super(Operation.class, "Operation");
    }

    public List<Operation> loadByFilter(Operation entityFilter) {
        throw new UnsupportedOperationException();
    }

    public Operation loadByExample(Operation entity) {
        throw new UnsupportedOperationException();
    }
    
	//	@Transactional
	//	public Operation selectOperation(Operation op) {
	//		try {
	//		      return (Operation) getEntityManager().createNamedQuery("SELECT op FROM Operation op " +
	//	              "WHERE op.id = :id").
	//	              setParameter("id", op.getId()).
	//	              getSingleResult();
	//		} catch (NoResultException e) {
	//		      return null;
	//		}
	//	}
	
	@Transactional
	public String selectObjHelper(Operation op){
		try {
		      return (String) getEntityManager().createNamedQuery("SELECT op.obj_helper FROM Operations op " +
	              "WHERE op.id = :id").
	              setParameter("id", op.getId()).
	              getSingleResult();
		} catch (NoResultException e) {
		      return null;
		}
	}
	
	
}
